<?php

m2import('base/ApplicationContext.php');
m2import('phpinchains/psp/ViewDispatcher.php');

/**
 * Default Action
 *
 */
class DefaultAction extends phpinchains_WebAction
{

    function execute (& $env, & $mapping, & $af)
    {
        print "execute";
        $this->callAction('DefaultAction', $af, '__process');
    }
    
    function addElement (& $env, & $mapping, & $af)
    {
        print "addElement";
        $this->callAction('DefaultAction', $af, '__process');
    }
    
    function __process (& $env, & $mapping, & $af)
    {
        $ctx  = & base_ApplicationContext::getInstance();
        $dbaCMS = $ctx->accessFactory->getInstanceOf("CMS");
        $doc = $dbaCMS->getCompleteDoc($af->get('doc_id'), $env->getSession('s_currentLang'));
        $af->setRef('doc', $doc);
        $af->setRef('cobj', $doc['elements']);
        $dispatcher = new ViewDispatcher($ctx->cfgPath('template').'cms/content', array('c', 'xics', 'cms'));
        $this->setResponse($dispatcher->dispatch($doc['contenttpl'].'.psp', $af));
    }
    
}

?>